<?php

class DB_APP_KEY_TENCENT extends ORM_Table {
    static protected $table_name = 'app_key_tencent';
    
    static public function getTableName($params = null) {
        //$table_name = self::$table_name.substr($params['article_type_id'], 0, 1);
        return self::$table_name;
    }

    /**
     * 更新授权信息
     * @param <type> $token_key
     * @param <type> $token_secret
     * @param <type> $uid
     * @param <type> $name
     * @return DB_APP_KEY_TENCENT
     */
    static public function setUpdate($token_key, $token_secret, $uid=0, $name='guest') {
        $has    = DAO_Finder::findOne(DB_APP_KEY_TENCENT, "token_key='$token_key' and token_secret='$token_secret'");
        if(!$has){
            $has    = new DB_APP_KEY_TENCENT();
            $has->setTokenKey($token_key);
            $has->setTokenSecret($token_secret);
            $has->setName($name);
            $has->setUid($uid);
            $has->save();
        }else{
            $has->setUid($uid);
            $has->save();
        }
        return $has;
    }
}

